package org.come.login;

import java.awt.Graphics;
import java.math.BigDecimal;
import java.util.Map;

import javax.swing.ImageIcon;

import org.come.bean.ConfigureBean;
import org.come.model.Configure;
import org.come.until.Music;
import org.come.until.UserMessUntil;
import org.come.view.View;

public class RaceView extends View{
	// 11返回
	private SpriteBtn fanghui;
	// 预选背景
	private ImageIcon yuxuan;
	// 预选柱子
	//private ImageIcon zuzhi;
	// 预选种族选择
	private SpriteBtn leis[];
	public static String zzs = "5";
	// 预选的种族描述
	private SpriteBtn leitext;
	public RaceView(LoginJpanel loginJpanel) {
		// TODO Auto-generated constructor stub
		this.setBounds(0, 0, 1024, 720);
		fanghui = new SpriteBtn("resource/NewUi/返回按钮全新", 10, 680, false);
		fanghui.setBounds(10, 680, 60, 30);
		fanghui.addMouseListener(new RoleMouslisten(11, fanghui, loginJpanel));
		this.add(fanghui);
		yuxuan = new ImageIcon("resource/NewUi/创建角色背景.png");
		//zuzhi = new ImageIcon("resource/NewUi/创建角色预选柱子.png");
		ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
		Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
		Configure configure = item.get(new BigDecimal(1));
		if(configure.getLzjskg() != null) {
			zzs = configure.getLzjskg();
		}
		if("4".equals(zzs)) {
			leis = new SpriteBtn[4];

		for (int i = 0; i < leis.length; i++) {
			if (i == 4) {
				leis[i] = new SpriteBtn("resource/NewUi/按钮_种族选择" + LoginJpanel.leipath(i), 737, 140, true);
				leis[i].setBounds(737, 140, 120, 630);
			} else {
				leis[i] = new SpriteBtn("resource/NewUi/按钮_种族选择" + LoginJpanel.leipath(i), 195 + i * 180, 140, true);
				leis[i].setBounds(195 + i * 180, 140, 120, 630);
			}
			leis[i].addMouseListener(new RaceMouslisten(i,leis[i],loginJpanel));
			this.add(leis[i]);
		}
		}else if("3".equals(zzs)) {
			leis = new SpriteBtn[3];
			for (int i = 0; i < leis.length; i++) {
				if (i == 4) {
					leis[i] = new SpriteBtn("resource/NewUi/按钮_种族选择" + LoginJpanel.leipath(i), 737, 140, true);
					leis[i].setBounds(737, 140, 120, 630);
				} else {
					leis[i] = new SpriteBtn("resource/NewUi/按钮_种族选择" + LoginJpanel.leipath(i), 220 + i * 240, 140, true);
					leis[i].setBounds(220 + i * 240, 140, 120, 630);
				}
				leis[i].addMouseListener(new RaceMouslisten(i,leis[i],loginJpanel));
				this.add(leis[i]);
			}
		}else {
			leis = new SpriteBtn[5];
			for (int i = 0; i < leis.length; i++) {
				if (i == 4) {
					leis[i] = new SpriteBtn("resource/NewUi/按钮_种族选择" + LoginJpanel.leipath(i), 737, 140, true);
					leis[i].setBounds(737, 140, 120, 630);
				} else {
					leis[i] = new SpriteBtn("resource/NewUi/按钮_种族选择" + LoginJpanel.leipath(i), 175 + i * 140, 140, true);
					leis[i].setBounds(175 + i * 140, 140, 120, 630);
				}
				leis[i].addMouseListener(new RaceMouslisten(i,leis[i],loginJpanel));
				this.add(leis[i]);
			}
		}


	}
	/**初始化预选种族描述文字 -1清除 1234人魔仙鬼*/
	public void yuxuantext(int type) {
		if (type != -1 && type != 4) {
		} else {
			leitext = null;
		}
	}
	@Override
	protected void paintComponent(Graphics g) {
		// TODO Auto-generated method stub
		super.paintComponent(g);
		g.drawImage(yuxuan.getImage(), 0, 0, 1024, 720, null);
		// 预选种族描述
		if (leitext != null) {
			leitext.draw(g);
		}
		//g.drawImage(zuzhi.getImage(), 330, 0, 0, 0, null);
		// 预选种族选择
		for (int i = 0; i < leis.length; i++) {
			leis[i].draw(g);
		}
		fanghui.draw(g);

	}
	public SpriteBtn[] getLeis() {
		return leis;
	}

}
